home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Software Contest 3 / FM Towns Software Contest 3.iso / exp / astral / a1 / game / source / autoplt.c < prev    next >
C/C++ Source or Header  |  1994-01-07  |  8KB  |  307 lines

  1. // "autoplt.c"
  2. // オートデモ用管理プログラム
  3.  
  4. #include <stdio.h>
  5. #include <spr.h>
  6. #include "wire3d.h"
  7. #include "sin8.c"
  8. #include "scmds.h"
  9.  
  10. // #define PUT_POSITION
  11.  
  12. SCREEN_LOCATE Screen[MAX_OBJECT];
  13. WIRE_SPACE Space[32];
  14.  
  15. ANGLE Angle[3]={0,0,0};
  16. int Offset[3]={0,0,0};
  17.  
  18. extern WIRE_OBJECT Object[MAX_OBJECT];
  19.  
  20. int End_code=0;
  21.  
  22. int Count=0;
  23.  
  24. int N_page=0,W_page=1;
  25.  
  26. int Hit_point[32];
  27. int Hit_size[32];
  28. int Hit_score[32];
  29. int Hit_my_fighter[32];
  30.  
  31. void pilot(int *movdata,void (*option)(void))
  32. {
  33.     int i,j,w;
  34.     
  35.     int obj_speed_rol[32][3],obj_speed_mov[32][3],obj_speed_movf[32];
  36.     int obj_locate[32][3];
  37.     int my_speed_movf=0,my_speed_mov3[3]={0,0,0},my_speed_rol[3]={0,0,0};
  38.     
  39.     int obj_num=32;
  40.     
  41.     int offset1[3]={0,0,0},offset2[3];
  42.     
  43.     int *movdata_start;
  44.     
  45.     for(i=0;i<32;i++){
  46.         obj_speed_rol[i][0]=0;
  47.         obj_speed_rol[i][1]=0;
  48.         obj_speed_rol[i][2]=0;
  49.         obj_speed_mov[i][0]=0;
  50.         obj_speed_mov[i][1]=0;
  51.         obj_speed_mov[i][2]=0;
  52.         obj_speed_movf[i]=0;
  53.     }
  54.     
  55.     for(i=0;i<obj_num;i++){
  56.         Space[i].obj_no=-1;
  57.     }
  58.     
  59.     movdata_start=movdata;
  60.     
  61.     for(;;){
  62.         RESTART:
  63.         if(Count==*movdata){
  64.             for(;;){
  65.                 switch(*(++movdata)){
  66.                 case 0: // 自機移動スピード変更(直進)
  67.                     my_speed_movf=*(++movdata);
  68.                     break;
  69.                 case 1: // 自機移動スピード変更(3方向)
  70.                     my_speed_mov3[0]=*(++movdata);
  71.                     my_speed_mov3[1]=*(++movdata);
  72.                     my_speed_mov3[2]=*(++movdata);
  73.                     break;
  74.                 case 2: // 自機回転スピード変更
  75.                     my_speed_rol[0]=*(++movdata);
  76.                     my_speed_rol[1]=*(++movdata);
  77.                     my_speed_rol[2]=*(++movdata);
  78.                     break;
  79.                 case 3: // 自機位置強制変更
  80.                     offset1[0]=*(++movdata)<<7;
  81.                     offset1[1]=*(++movdata)<<7;
  82.                     offset1[2]=*(++movdata)<<7;
  83.                     break;
  84.                 case 4: // 自機角度強制変更
  85.                     Angle[0]=*(++movdata);
  86.                     Angle[1]=*(++movdata);
  87.                     Angle[2]=*(++movdata);
  88.                     break;
  89.                 case 20: // 物体表示(絶対座標)
  90.                     i=*(++movdata);
  91.                     Space[i].obj_no=*(++movdata);
  92.                     Hit_size[i]=Object[*movdata].size>>4;
  93.                     Space[i].angle[0]=*(++movdata);
  94.                     Space[i].angle[1]=*(++movdata);
  95.                     Space[i].angle[2]=*(++movdata);
  96.                     obj_locate[i][0]=*(++movdata)<<7;
  97.                     obj_locate[i][1]=*(++movdata)<<7;
  98.                     obj_locate[i][2]=*(++movdata)<<7;
  99.                     Hit_point[i]=*(++movdata);
  100.                     Hit_score[i]=*(++movdata);
  101.                     Hit_my_fighter[i]=*(++movdata);
  102.                     obj_speed_movf[i]=0;
  103.                     obj_speed_mov[i][0]=0;
  104.                     obj_speed_mov[i][1]=0;
  105.                     obj_speed_mov[i][2]=0;
  106.                     obj_speed_rol[i][0]=0;
  107.                     obj_speed_rol[i][1]=0;
  108.                     obj_speed_rol[i][2]=0;
  109.                     break;
  110.                 case 21: // 物体表示(オブジェクト相対座標)
  111.                     i=*(++movdata);
  112.                     Space[i].obj_no=*(++movdata);
  113.                     Hit_size[i]=Object[*movdata].size>>4;
  114.                     Space[i].angle[0]=*(++movdata);
  115.                     Space[i].angle[1]=*(++movdata);
  116.                     Space[i].angle[2]=*(++movdata);
  117.                     j=*(++movdata);
  118.                     if(Space[j].obj_no==-1){
  119.                         Space[i].obj_no=-1;
  120.                     }
  121.                     obj_locate[i][0]=obj_locate[j][0];
  122.                     obj_locate[i][1]=obj_locate[j][1];
  123.                     obj_locate[i][2]=obj_locate[j][2];
  124.                     Hit_point[i]=*(++movdata);
  125.                     Hit_score[i]=*(++movdata);
  126.                     Hit_my_fighter[i]=*(++movdata);
  127.                     obj_speed_movf[i]=0;
  128.                     obj_speed_mov[i][0]=0;
  129.                     obj_speed_mov[i][1]=0;
  130.                     obj_speed_mov[i][2]=0;
  131.                     obj_speed_rol[i][0]=0;
  132.                     obj_speed_rol[i][1]=0;
  133.                     obj_speed_rol[i][2]=0;
  134.  
  135.                     break;
  136.                 case 22: // 物体表示(オブジェクト相対座標・角度)
  137.                     i=*(++movdata);
  138.                     Space[i].obj_no=*(++movdata);
  139.                     Hit_size[i]=Object[*movdata].size>>4;
  140.                     Space[i].angle[0]=*(++movdata);
  141.                     Space[i].angle[1]=*(++movdata);
  142.                     Space[i].angle[2]=*(++movdata);
  143.                     j=*(++movdata);
  144.                     if(Space[j].obj_no==-1){
  145.                         Space[i].obj_no=-1;
  146.                     }
  147.                     Space[i].angle[0]=Space[j].angle[0];
  148.                     Space[i].angle[1]=Space[j].angle[2];
  149.                     Space[i].angle[2]=Space[j].angle[2];
  150.                     obj_locate[i][0]=obj_locate[j][0];
  151.                     obj_locate[i][1]=obj_locate[j][1];
  152.                     obj_locate[i][2]=obj_locate[j][2];
  153.                     Hit_point[i]=*(++movdata);
  154.                     Hit_score[i]=*(++movdata);
  155.                     Hit_my_fighter[i]=*(++movdata);
  156.                     obj_speed_movf[i]=0;
  157.                     obj_speed_mov[i][0]=0;
  158.                     obj_speed_mov[i][1]=0;
  159.                     obj_speed_mov[i][2]=0;
  160.                     obj_speed_rol[i][0]=0;
  161.                     obj_speed_rol[i][1]=0;
  162.                     obj_speed_rol[i][2]=0;
  163.                     break;
  164.                 case 23: // 物体表示(自機オフセット)
  165.                     i=*(++movdata);
  166.                     Space[i].obj_no=*(++movdata);
  167.                     Hit_size[i]=Object[*movdata].size>>4;
  168.                     Space[i].angle[0]=*(++movdata);
  169.                     Space[i].angle[1]=*(++movdata);
  170.                     Space[i].angle[2]=*(++movdata);
  171.                     obj_locate[i][0]=offset1[0]+(*(++movdata)<<7);
  172.                     obj_locate[i][1]=offset1[1]+(*(++movdata)<<7);
  173.                     obj_locate[i][2]=offset1[2]+(*(++movdata)<<7);
  174.                     Hit_point[i]=*(++movdata);
  175.                     Hit_score[i]=*(++movdata);
  176.                     Hit_my_fighter[i]=*(++movdata);
  177.                     obj_speed_movf[i]=0;
  178.                     obj_speed_mov[i][0]=0;
  179.                     obj_speed_mov[i][1]=0;
  180.                     obj_speed_mov[i][2]=0;
  181.                     obj_speed_rol[i][0]=0;
  182.                     obj_speed_rol[i][1]=0;
  183.                     obj_speed_rol[i][2]=0;
  184.                     break;
  185.                 case 30: // 物体移動スピード変更(直進)
  186.                     i=*(++movdata);
  187.                     obj_speed_movf[i]=*(++movdata);
  188.                     break;
  189.                 case 31: // 物体移動スピード変更
  190.                     i=*(++movdata);
  191.                     obj_speed_mov[i][0]=*(++movdata)<<7;
  192.                     obj_speed_mov[i][1]=*(++movdata)<<7;
  193.                     obj_speed_mov[i][2]=*(++movdata)<<7;
  194.                     break;
  195.                 case 32: // 物体回転スピード変更
  196.                     i=*(++movdata);
  197.                     obj_speed_rol[i][0]=*(++movdata);
  198.                     obj_speed_rol[i][1]=*(++movdata);
  199.                     obj_speed_rol[i][2]=*(++movdata);
  200.                     break;
  201.                 case 40: // 物体No.変更(アニメーション)
  202.                     i=*(++movdata);
  203.                     if(Hit_point[i]!=0){
  204.                         Space[i].obj_no=*(++movdata);
  205.                     }
  206.                     else{
  207.                         ++movdata;
  208.                     }
  209.                     break;
  210.                 case 41: // 物体位置変更
  211.                     i=*(++movdata);
  212.                     obj_locate[i][0]=*(++movdata)<<7;
  213.                     obj_locate[i][1]=*(++movdata)<<7;
  214.                     obj_locate[i][2]=*(++movdata)<<7;
  215.                     break;
  216.                 case 42: // 物体角度変更
  217.                     i=*(++movdata);
  218.                     Space[i].angle[0]=*(++movdata);
  219.                     Space[i].angle[1]=*(++movdata);
  220.                     Space[i].angle[2]=*(++movdata);
  221.                     break;
  222.                 case 43: // 物体位置変更(自機オフセット)
  223.                     i=*(++movdata);
  224.                     obj_locate[i][0]=offset1[0]+(*(++movdata)<<7);
  225.                     obj_locate[i][1]=offset1[1]+(*(++movdata)<<7);
  226.                     obj_locate[i][2]=offset1[2]+(*(++movdata)<<7);
  227.                     break;
  228.                 case 90: // ループ
  229.                     movdata=movdata_start;
  230.                     Count=0;
  231.                     goto RESTART;
  232.                 case 99: // エンドマーク
  233.                     goto EXIT_anarize;
  234.                 default: // 処理終了
  235.                     return;
  236.                 }
  237.             }
  238.             EXIT_anarize:
  239.             movdata++;
  240.         }
  241.         Count++;
  242.         
  243.         Angle[0]+=my_speed_rol[0];
  244.         Angle[1]+=my_speed_rol[1];
  245.         Angle[2]+=my_speed_rol[2];
  246.         
  247.         offset2[1]=( my_speed_movf*sin_data[Angle[0]]);
  248.         offset2[2]=( my_speed_movf*cos_data[Angle[0]])>>7;
  249.         offset2[0]=(-offset2[2] * sin_data[Angle[1]]);
  250.         offset2[2]=( offset2[2] * cos_data[Angle[1]]);
  251.         
  252.         offset1[0]+=offset2[0]+(my_speed_mov3[0]<<7);
  253.         offset1[1]+=offset2[1]+(my_speed_mov3[1]<<7);
  254.         offset1[2]+=offset2[2]+(my_speed_mov3[2]<<7);
  255.         
  256.         Offset[0]=offset1[0]>>7;
  257.         Offset[1]=offset1[1]>>7;
  258.         Offset[2]=offset1[2]>>7;
  259.         
  260.         for(i=0;i<32;i++){
  261.             if(Space[i].obj_no!=-1){
  262.                 Space[i].angle[0]+=obj_speed_rol[i][0];
  263.                 Space[i].angle[1]+=obj_speed_rol[i][1];
  264.                 Space[i].angle[2]+=obj_speed_rol[i][2];
  265.                 
  266.                 obj_locate[i][0]+=obj_speed_mov[i][0];
  267.                 obj_locate[i][1]+=obj_speed_mov[i][1];
  268.                 obj_locate[i][2]+=obj_speed_mov[i][2];
  269.                 
  270.                 if(obj_speed_movf[i]!=0){
  271.                     offset2[1]=( obj_speed_movf[i] *
  272.                      sin_data[Space[i].angle[0]]);
  273.                     offset2[2]=( obj_speed_movf[i] *
  274.                      cos_data[Space[i].angle[0]])>>7;
  275.                     offset2[0]=(-offset2[2] * sin_data[Space[i].angle[1]]);
  276.                     offset2[2]=( offset2[2] * cos_data[Space[i].angle[1]]);
  277.                     obj_locate[i][0]+=offset2[0];
  278.                     obj_locate[i][1]+=offset2[1];
  279.                     obj_locate[i][2]+=offset2[2];
  280.                 }
  281.                 
  282.                 Space[i].locate[0]=obj_locate[i][0]>>7;
  283.                 Space[i].locate[1]=obj_locate[i][1]>>7;
  284.                 Space[i].locate[2]=obj_locate[i][2]>>7;
  285.             }
  286.         }
  287.         
  288.         #ifdef PUT_POSITION
  289.         printf("Count%5d:Angle=%3d,%3d,%3d Position=%6d,%6d,%6d\n",Count, \
  290.          Angle[0],Angle[1],Angle[2],Offset[0],Offset[1],Offset[2]);
  291.         #endif
  292.         
  293.         if(End_code!=0)return;
  294.         w=N_page;N_page=W_page;W_page=w;
  295.         
  296.         wait_VSYNC();
  297.         chgpage(N_page);
  298.         clear_screen(W_page,6);
  299.         star(Angle,W_page);
  300.         
  301.         wirespace(Angle,Offset,obj_num,W_page);
  302.         option();
  303.     }
  304. }
  305.  
  306.  
  307.